package com.corgi.dubbo.consumer.service.impl;

import com.corgi.dubbo.api.bean.UserAddress;
import com.corgi.dubbo.api.service.OrderService;
import com.corgi.dubbo.api.service.UserService;
import com.google.common.collect.Lists;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @title: OrderServiceImpl
 * @description:
 * @author: dengmiao
 * @create: 2019-09-24 16:07
 **/
@Service
public class OrderServiceImpl implements OrderService {

	@Reference
	private UserService userService;

	@HystrixCommand(fallbackMethod = "failBack")
	@Override
	public List<UserAddress> initOrder(String userId) {
		System.out.println("got userId: " + userId);
		return userService.findList(userId);
	}

	/**
	 * 出错的回调
	 * @param userId
	 * @return
	 */
	public List<UserAddress> failBack(String userId) {
		return Lists.newArrayList();
	}
}
